﻿using System;
using System.Collections;
using System.Linq;
using UnityEngine;

// Token: 0x0200012F RID: 303
public class IntervalSwitchView : MonoBehaviour
{
	// Token: 0x060006D2 RID: 1746 RVA: 0x0002854C File Offset: 0x0002674C
	private void OnEnable()
	{
		if (this._coroutine == null)
		{
			this._coroutine = this.DoSwitch();
		}
		base.StartCoroutine(this._coroutine);
	}

	// Token: 0x060006D3 RID: 1747 RVA: 0x00028574 File Offset: 0x00026774
	private void OnDisable()
	{
		base.StopCoroutine(this._coroutine);
	}

	// Token: 0x060006D4 RID: 1748 RVA: 0x00028584 File Offset: 0x00026784
	private IEnumerator DoSwitch()
	{
		Transform firstPt = this._viewPoints.FirstOrDefault<Transform>();
		IntervalSwitchView.SwitchView(this._camera.transform, firstPt);
		for (;;)
		{
			foreach (Transform pt in this._viewPoints)
			{
				yield return new WaitForSeconds(this._intervalSec);
				IntervalSwitchView.SwitchView(this._camera.transform, pt);
			}
			yield return null;
		}
		yield break;
	}

	// Token: 0x060006D5 RID: 1749 RVA: 0x000285A0 File Offset: 0x000267A0
	private static void SwitchView(Transform cameraTransform, Transform pointTransform)
	{
		cameraTransform.SetParent(pointTransform, false);
		cameraTransform.localPosition = Vector3.zero;
		cameraTransform.localRotation = Quaternion.identity;
		cameraTransform.localScale = Vector3.one;
	}

	// Token: 0x040006B9 RID: 1721
	[SerializeField]
	private Camera _camera;

	// Token: 0x040006BA RID: 1722
	[SerializeField]
	private Transform[] _viewPoints;

	// Token: 0x040006BB RID: 1723
	[SerializeField]
	private float _intervalSec = 3f;

	// Token: 0x040006BC RID: 1724
	private IEnumerator _coroutine;
}
